﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace JEng_Editor.MaterialControl
{
    public class MaterialEditorControl : Control
    {
        private int _gridSize = 50;

        /// <summary>
        /// The zoom level of the object
        /// </summary>
        public int ZoomLevel { get; set; }

        public MaterialEditorControl() {
            this.BackColor = Color.Beige;
            this.AllowDrop = true;
        }

        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);

            string data = (string)drgevent.Data.GetData(DataFormats.Text);

            MessageBox.Show(data);
        }


        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            //background brush (standard grey)
            Brush bgrndB = Brushes.DarkGray;
            //grid line pen (lighter grey)
            Pen gridLineP = Pens.Gray;

            //draw the background
            e.Graphics.FillRectangle(bgrndB, ClientRectangle);

            //draw the grid
            for (int x = 0; x < (int)(ClientRectangle.Width / _gridSize); x++)
            {
                e.Graphics.DrawLine(gridLineP, new Point(x * _gridSize, 0), new Point(x * _gridSize, ClientRectangle.Bottom));
            }
            for (int y = 0; y < (int)(ClientRectangle.Height / _gridSize); y++)
            {
                e.Graphics.DrawLine(gridLineP, new Point(0, y * _gridSize), new Point(ClientRectangle.Right, y * _gridSize));
            }
                    

                    


        }
    }
}
